package com.bangdream.michelia.view.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.LayoutRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.exam.ExamBean;
import com.bangdream.michelia.tool.RoundCornerImageView;
import com.bangdream.michelia.utils.ImageLoadUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * @date on 2018/6/18 16:29
 * @email 909732184@qq.com
 * 任务-问卷的列表适配器
 */
public class TaskQuListAdapter extends BaseQuickAdapter<ExamBean, BaseViewHolder>  {// RecyclerView.Adapter {
    private Context context;
    private LayoutInflater layoutInflater;
    private OnItemClickListener onItemClickListener;
    private List<ExamBean> data;
    private int selectTextColor,selectedTextColor;
    private Drawable selectBg,selectedBg;

    public TaskQuListAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }
    /*public OnItemClickListener getOnItemClickListener() {
        return onItemClickListener;
    }*/


    public void setData(List<ExamBean> data) {
        this.data = data;
    }

    public List<ExamBean> getData() {
        return data;
    }

   /* public TaskQuListAdapter(Context context) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        selectTextColor = ContextCompat.getColor(context,R.color.text_color);
        selectedTextColor = ContextCompat.getColor(context,R.color.common_red);
        selectBg = ContextCompat.getDrawable(context,R.drawable.cutting_gray_line);
        selectedBg = ContextCompat.getDrawable(context,R.drawable.cutting_red_line);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(layoutInflater.inflate(R.layout.main_task_quest_adapter_item,parent,false));
    }*/

    @Override
    protected void convert(BaseViewHolder helper, ExamBean item) {
        ImageLoadUtils.ImageLoad(mContext,item.getFaceUri(), helper.getView(R.id.ivIcon),-1);
        helper.setText(R.id.tvCollection,item.getClickNumber()+"");
        helper.setText(R.id.tvTitle,item.getTitle()+"");
        helper.setText(R.id.tvPeopleNumber,item.getCntQuestion()+"");
        helper.setText(R.id.tvContent,"有效时间："+item.getStartDate()+" 至 "+item.getEndDate()+"");
    }

   /* @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = null;
        if(holder instanceof ViewHolder){
            viewHolder = (ViewHolder) holder;
            viewHolder.position = position;
            ExamBean bean = data.get(position);
            ImageLoadUtils.ImageLoad(context,bean.getFaceUri(),viewHolder.ivIcon,-1);
            viewHolder.tvCollection.setText(bean.getClickNumber()+"");
            viewHolder.tvTitle.setText(bean.getTitle()+"");
            viewHolder.tvPeopleNumber.setText(bean.getCntQuestion()+"");
            viewHolder.tvContent.setText("结束时间："+bean.getStartDate()+" 至 "+bean.getEndDate()+"");
           *//* CoursesBean bean = data.get(position);
            ImageLoadUtils.ImageLoad(context,bean.getFaceUrl(),viewHolder.ivIcon,-1);
            viewHolder.tvTitle.setText(bean.getName()+"");
            viewHolder.tvContent.setText(Html.fromHtml(bean.getIntroduction()+""));
            viewHolder.tvCollection.setText(bean.getCollectCount()+"");
            viewHolder.tvZan.setText(bean.getBuyCount()+"");
            viewHolder.tvPeopleNumber.setText(bean.getCollectCount()+"");

            if(bean.isCollect()){
                viewHolder.btnCollection.setBackground(selectedBg);
                viewHolder.tvCollection.setTextColor(selectedTextColor);
                viewHolder.ivCollection.setImageResource(R.mipmap.icon_collection2);
            }else {
                viewHolder.btnCollection.setBackground(selectBg);
                viewHolder.tvCollection.setTextColor(selectTextColor);
                viewHolder.ivCollection.setImageResource(R.mipmap.icon_collection1);
            }

            if(bean.getLearnStatus()!=null) {
                viewHolder.tvState.setVisibility(View.VISIBLE);
                viewHolder.tvState.setText(StausUtils.coursesStateToText(bean.getLearnStatus()));
            }else {
                viewHolder.tvState.setVisibility(View.GONE);
            }*//*

        }
    }*/
}
